package string;


public class Demo_StringMethod3 {
    public static void main(String[] args) {
        extracted();
        extracted1();
        extracted2();
        extracted3();
        extracted5();


    }

    private static void extracted5() {
        String str1 = "WangZIXIAO";
        String str2 = "wangZiXIaO";

        //将字符串中的所有字符转换成小写的
        String str1_1 = str1.toLowerCase();

        //将字符串中的所有字符转换成大写的
        String str2_2 = str2.toUpperCase();
        System.out.println(str1_1);
        System.out.println(str2_2);

        //用+号拼接字符串更强大，可以用字符串与任意类型相加
        System.out.println(str1 + str2);

        //str1.concat(str2)将两个字符串拼接
        System.out.println(str1.concat(str2));
    }

    private static void extracted4() {
        Person p1 = new Person("wzx", 25);
        System.out.println("***********************");
        System.out.println(p1);//底层调用的是toString()方法
        System.out.println(String.valueOf(p1));//底层调用的是toString()方法
    }

    private static void extracted3() {
        String s = String.valueOf(100);
        //将100转换为字符串
    }

    private static void extracted2() {
        char[] arr = {'a', 'b', 'c'};
        String s = String.valueOf(arr);
        //将字符数组转换成字符串
        System.out.println(s);
    }

    private static void extracted1() {
        String s = "successful";
        char[] arr = s.toCharArray();//将字符串转换啊成字符数组
        for (char v : arr) {
            System.out.print(v + " ");
        }
    }

    private static void extracted() {
        String s1 = "abc";
        byte[] arr = s1.getBytes();
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        /*
        通过gbk码表将字符串转换成字节数组
        编码：把我们看的懂的转换为计算机看得懂的
        gbk码表一个中文代表两个字节
        gbk码表的特点，中文的第一个字节肯定是负数
         */
        System.out.println();
        String s2 = "你好你还";
        byte[] arr2 = s2.getBytes();
        for (int i = 0; i < arr2.length; i++) {
            System.out.print(arr2[i] + " ");
        }
        System.out.println();
    }
}


class Person {
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person() {
    }

    public String getName() {

        return name;
    }

    public void setName(String name) {

        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {

        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
